//
//  FilterCommonCollectionViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/8/7.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "FilterCommonCollectionViewCell.h"
#import "CommonItemModel.h"

@interface FilterCommonCollectionViewCell ()

@property (strong, nonatomic) UILabel *nameBtn;
@property (copy, nonatomic) NSString *itemId;

@end

@implementation FilterCommonCollectionViewCell

+ (NSString *)cellReuseIdentifier {
    return @"FilterCommonCollectionViewCell";
}

- (instancetype)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {

        [self.contentView addSubview:self.nameBtn];

        __weak typeof(self) weakSelf = self;
        [self.nameBtn mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.mas_equalTo(weakSelf.contentView.mas_left);
            make.right.mas_equalTo(weakSelf.contentView.mas_right);
            make.top.mas_equalTo(weakSelf.contentView.mas_top);
            make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom);

        }];
    }

    return self;
}

- (void)updateCellWithModel:(CommonItemModel *)model {

    self.nameBtn.text = model.itemName;
    self.itemId = model.itemId;
    [self tap2SelectItem:model.selected];

}

- (void)tap2SelectItem:(BOOL)selected {
    
    if (selected) {

        self.backgroundColor = WhiteColor;
        self.nameBtn.textColor = Colorff0000;
        
        self.layer.borderWidth = .5f;
        self.layer.borderColor = Colorff0000.CGColor;
        self.layer.cornerRadius = jisuan(10);
    } else {

        self.backgroundColor = Colorefefef;
        self.nameBtn.textColor = Color333333;
        self.layer.borderWidth = 0;
        self.layer.cornerRadius = jisuan(10);
    
    }
    
}

#pragma mark -lazy

- (UILabel *)nameBtn {
    
    if (!_nameBtn) {
        
        _nameBtn = [[UILabel alloc] init];
        _nameBtn.textAlignment = NSTextAlignmentCenter;
        _nameBtn.font = Font(20);
    
    }
    
    return _nameBtn;
    
}

@end
